/*
 * File:   infint.h
 * Author: ScaV
 *
 * Created on 17 РЎРµРЅС‚СЏР±СЂСЊ 2011 Рі., 23:01
 */

#ifndef INFINT_H
#define	INFINT_H

#include <list>
#include <string>
#include <iostream>

typedef short infclust;
typedef unsigned long long infpr;
typedef std::list <infclust> arlist;
typedef std::list <infclust>::iterator ariter;
typedef std::list <infclust>::reverse_iterator arriter;
typedef std::string::reverse_iterator strriter;

class infint {
private:
	int sign;
	arlist *digit;
	infint getSum(int sgn, const infint& l2);
	infint getProduct(const infint& l);
	infint getDivide(infint& l, infint* tail = NULL);
	infint getPow(infint l2);
	int getEqualSigns(const infint& l2);
	int getEqualDigits(const infint& l2);
	long getLength();
	void copyFrom(const infint& orig);
	long cutFrom(infint& orig, long start, long numof);

public:
	infint();
	infint(std::string str);
	infint(long long num);
	infint(const infint& orig);
	virtual ~infint();

	int getClustSize();
	infclust getClustTemplate();
	infclust getClustMax();
	int setDigit(long long num);
	int setDigit(std::string str);
	int setModule(long long num);
	int setModule(std::string str);
	int setSign(char m);
	long size() { return getLength(); };
	long length() { return getLength(); };
	infint& operator =(infint src);
	infint& operator ++();
	infint operator ++(int);
	infint& operator --();
	infint operator --(int);
	infint operator -();
	infint getFact();
	infint getFib();
	short operator [](int index);
	void operator +=(infint n);
	void operator -=(infint n);
	void operator *=(infint n);
	void operator /=(infint n);
	void operator ^=(infint n);
	friend infint operator +(infint l1, infint l2);
	friend infint operator -(infint l1, infint l2);
	friend infint operator *(infint l1, infint l2);
	friend infint operator /(infint l1, infint l2);
	friend infint operator %(infint l1, infint l2);
	friend infint operator ^(infint l1, infint l2);
	friend infint operator |(infint l1, infint l2); //НОД
	friend infint operator &(infint l1, infint l2); //НОК
	friend bool operator ==(infint l1, infint l2);
	friend bool operator !=(infint l1, infint l2);
	friend bool operator >(infint l1, infint l2);
	friend bool operator <(infint l1, infint l2);
	friend bool operator >=(infint l1, infint l2);
	friend bool operator <=(infint l1, infint l2);
	friend std::ostream& operator <<(std::ostream& s, infint t);
};

#endif	/* INFINT_H */

